#include <Windows.h>
#include <string>
#include <list>
using std::list;
#include "Util\WzBinaryReader.h"
#include "WzMapleVersion.h"
#include "WzObjectType.h"
#include "WzPropertyType.h"
#include "IWzFile.h"
#include "IWzObject.h"
#include "WzHeader.h"
#include "IWzImageProperty.h"

#include "IWzPropertyContainer.h"

/**
** WZ File Library
** Wrapper class for accessing WZ Files and Objects.
**/

class WZLib
{
	// Instance of WZLib. Prevent Multiple Instances.
private:
	volatile static WZLib* m_Instance;

	// Contains the Key used to Encrypt/Decrypt Data.
	unsigned char* m_WZFileKey;


public:
	WZLib(unsigned char* WZFileKey)
	{
		m_WZFileKey = WZFileKey;

		// Finish!
	}

	// CRITICAL SECTION
	// ACCESCES THE m_Instance volatile member;
	// If instance does not exist, it creates the instance.
	volatile static WZLib* GetInstance()
	{
		CRITICAL_SECTION cs;

		InitializeCriticalSection(&cs);
		EnterCriticalSection(&cs);

		if(m_Instance == NULL)
		{
			//m_Instance = new WZLib(CSettingsManager.GetInstance().GetWZKey());
			return m_Instance;
		}
		else
		{
			return m_Instance;
		}

		LeaveCriticalSection(&cs);
		delete &cs;
	}
}